<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%@include file="/admin/include/includeAdminTaglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <t:base type="jquery,easyui1.5"></t:base>
    <link rel="stylesheet" href="${frontPath}/resource/bootstrap3/css/bootstrap.min.css">
    <script src="${frontPath}/resource/bootstrap3/js/bootstrap.min.js"></script>
    <style>
        * {
            font-size: 12px;
        }
    </style>
</head>
<body>
<div class="easyui-panel" fit="true" title="增加评估记录" style="padding:10px;">
    <form method="post" id="formObj" name="formObj" autocomplete="off">
        选择表单:<input class="easyui-combobox" name="formId" id="formId" style="width:30%;" data-options="
                    url:'${frontPath}/admin/evaluation/evaluationFormList',
                    method:'post',
                    valueField:'formId',
                    textField:'formName',
                    panelHeight:'auto',editable:false
                    ">
        <div style="clear:both;margin-top:20px;" id="loadForm"></div>
    </form>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">提交</a>
        <a href="/admin/evaluation/recordList?serviceId=${param.serviceId}" class="easyui-linkbutton" style="width:80px">返回</a>
    </div>
</div>
<script>
    $('#formId').combobox({
        onSelect: function(record){
            $("#loadForm").load("${frontPath}/admin/evaluation/loadForm",{"m":Math.random(),"formId":record.formId})
            //console.info(record)
        }
    });
    $("#formObj").form({
        url: '${frontPath}/admin/evaluation/recordPost',
        onSubmit: function () {
            var flag = $(this).form('validate');
            var resultArray = new Array();
            $(".assessmentStandardValue").each(function () {
                var item = new Object()
                item["itemId"] = new Number($(this).attr("name"))
                item["formId"] = new Number($(this).attr("formId"))
                item["dataId"] = new Number($(this).attr("dataId"))
                item["formName"] =$(this).attr("formName")
                item["standardValueId"] = new Number($(this).val())
                item["serviceId"] = ${param.serviceId}
                item["createUserId"] = ${curAdminId}
                resultArray.push(item)
            })
            $.ajax({
                url: "${frontPath}/admin/evaluation/recordPost",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                type: "POST",
                data: JSON.stringify(resultArray),
                success: function (resultObj) {
                    var tip = "成功"
                    if (!resultObj.success) {
                        tip = "失败"
                    }
                    top.showMessage("新增评估记录" + tip)
                    top.contentIFrameLoadUrl("", "${frontPath}/admin/evaluation/recordList?serviceId=${param.serviceId}")
                }
            })
            //console.info(JSON.stringify(resultArray))
            return false;
            //return flag;
        },
        success: function (resultObj) {
            var tip = "成功"
            resultObj = $.parseJSON(resultObj)
            if (!resultObj.success) {
                tip = "失败"
            }
            top.showMessage("${empty serviceModel.serviceId ? '添加' : '修改'}被照护人信息" + tip)
            top.contentIFrameLoadUrl("", "${frontPath}/admin/service/list")
        }
    })
    function submitForm(){
        $("#formObj").submit()
    }
</script>
</body>
</html>